import {Component, OnInit} from "@angular/core";
import {Page} from "../../../public/util/page";
import {UserService} from "../user.service";
import {States} from "../../../public/setting/enums";
import {SettingUrl} from "../../../public/setting/setting_url";

@Component({
  selector: 'app-user-bank-card-list',
  templateUrl: './user-bank-card-list.component.html',
  styleUrls: ['./user-bank-card-list.component.scss']
})
export class UserBankCardListComponent implements OnInit {
  public searchParams: any = {};//搜索参数
  public userBankCardList: Page = new Page(); //供应商
  public _loading: boolean = false;
  public routerLinks = SettingUrl.ROUTERLINK;//路由
  public states = States;       // 状态

  constructor(private userService: UserService) {
  }

  ngOnInit() {
    this.queryUserBankCardList()
  }

  /**
   * 查询userBankCard列表
   * @param curPage 当前页
   */
  queryUserBankCardList(curPage?: number) {
    this._loading = true;
    if (curPage) this.userBankCardList.curPage = curPage;//当有页码时，查询该页数据
    this.userBankCardList.params = {
      curPage: this.userBankCardList.curPage, //目标页码
      pageSize: this.userBankCardList.pageSize, //每页条数
      bankMan: this.searchParams.bankMan, //搜索条件-bankMan
    };
    this.userService.getUserBankCardList(this.userBankCardList.params).then((res: Page) => {
      this._loading = false;
      this.userBankCardList = res;
    }).catch(err => {
      this._loading = false;
    })
  }

  /**
   * 重置搜索
   */
  resetSearch() {
    this.searchParams = {};
    this.queryUserBankCardList(1)
  }
}
